/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.andersen.web.utils;

import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;

/**
 *
 * @author Corvus 11
 */
@Component
public class RequestUtils {
    
    private static final Logger LOG = Logger.getLogger(RequestUtils.class);
    
    public static final int DATATABLE_INT_INVALID = Integer.MIN_VALUE;
    public static final long DATATABLE_LONG_INVALID = Long.MIN_VALUE;
    
    public int getIntegerParam(HttpServletRequest request, String paramName) {
        try {
            int result = Integer.parseInt(request.getParameter(paramName));
            return result;
        } catch (NumberFormatException exc) {
            return DATATABLE_INT_INVALID;
        }
    }
    
    public long getLongParam(HttpServletRequest request, String paramName) {
        try {
            long result = Long.parseLong(request.getParameter(paramName));
            return result;
        } catch (NumberFormatException exc) {
            return DATATABLE_LONG_INVALID;
        }
    }
}
